import { Component, OnInit } from '@angular/core';
// declare const qq: any;         // 2. 消除 tsc 编译器报错
// import { OfflineOptions, ControlAnchor, NavigationControlType } from 'angular2-baidu-map';
import {MapService} from '../../../lib/service/map.service';

@Component({
  selector: 'app-show',
  templateUrl: 'show.component.html',
  styleUrls: ['show.component.scss'],
  providers: [
    MapService
  ]
})
export class ShowComponent implements OnInit {
  // 备份
  /*cardAdvancedInfo = {
    text_image_list: [
      {
        img_url: '../../../assets/images/banner1.jpg',
        text: 'banner1测试'
      },
      {
        img_url: '../../../assets/images/banner2.jpg',
        text: 'banner2测试'
      },
    ]
  };*/

  // options = {
  //   zoom: 8,
  //   // center: 'qq.maps.LatLng(39.916527, 116.397128)'
  // };
  province: string;
  city: string;
  county: string;
  address: string;
  newLatitude: number;
  newLongitude: number;

  opts: any;

  constructor(private mapService: MapService) {}

  ngOnInit() {
    this.opts = {
      center: {
        latitude: 29.866027,
        longitude: 121.628577
      },
      zoom: 11,
    };
  }

  // loadMap(map: any) {
  //   console.log('map instance here', map);
  // }
  //
  // clickMarker(marker: any) {
  //   console.log('The clicked marker is', marker);
  // }
  //
  // clickmap(e: any) {
  //   console.log(`Map clicked with coordinate: ${e.point.lng}, ${e.point.lat}`);
  // }
  // mapSearch() {
  //   const query = this.address;
  //   const region = this.province + this.city + this.county;
  //   this.mapService.localSearch(query, region).subscribe(
  //     rs => {
  //       if (rs === 0) {
  //         this.newLatitude = rs.results[0].location.lat;
  //         this.newLongitude = rs.results[0].location.lng;
  //         this.updateCoordinate();
  //       } else {
  //         alert(rs.status + ',' + rs.message);
  //       }
  //     }
  //   );
  // }
  updateCoordinate() {
    this.opts = {
      center: {
        latitude: this.newLatitude,
        longitude: this.newLongitude,
      }
    };
  }
  // 备份
  /*upTextImage(i: number) {
    if (i <= 0) {
      return;
    }
    [this.cardAdvancedInfo.text_image_list[i], this.cardAdvancedInfo.text_image_list[i - 1]] =
      [this.cardAdvancedInfo.text_image_list[i - 1], this.cardAdvancedInfo.text_image_list[i]];
  }

  downTextImage(i: number) {
    if (i >= this.cardAdvancedInfo.text_image_list.length - 1) {
      return;
    }
    [this.cardAdvancedInfo.text_image_list[i], this.cardAdvancedInfo.text_image_list[i + 1]] =
      [this.cardAdvancedInfo.text_image_list[i + 1], this.cardAdvancedInfo.text_image_list[i]];
  }*/
}
